﻿///Author : Bui Huu Loc
///Date : 30-03-2009
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using LibKetoan;
using Excel;

namespace Ketoan
{	
	public class frmReport_dtns : System.Windows.Forms.Form
	{
		
		#region Controls
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.GroupBox grpNen;
		private LibList.List listNhomMuc;
		protected txtListBox.txtListBox txtTenNhomMuc;
		private txtListBox.txtListBox txtNhomMuc;
		private System.Windows.Forms.TextBox txttenhoatdong;
		private System.Windows.Forms.TextBox txthoatdong;
		private System.Windows.Forms.TextBox txttenchuong;
		private System.Windows.Forms.TextBox txtchuong;
		private System.Windows.Forms.TextBox txtnhombc;
		private System.Windows.Forms.TextBox txttennhombc;
		protected txtListBox.txtListBox txtTenloaikhoan;
		private txtListBox.txtListBox txtLoaikhoan;
		private System.Windows.Forms.Label lblnhombc;
		private txtListBox.txtListBox txtSotaikhoan;
		private System.Windows.Forms.Label lblChuong;
		private System.Windows.Forms.Label lblHoatDong;
		private System.Windows.Forms.Label lblLoaikhoan;
		protected txtListBox.txtListBox txtTentaikhoan;
		private System.Windows.Forms.Label lblTaikhoan;
		private LibList.List listNguon;
		protected txtListBox.txtListBox txtTenNguonGoc;
		private txtListBox.txtListBox txtNguonGoc;
		private System.Windows.Forms.Panel pnlButton;
		private LibList.List listTaikhoan;
		private LibList.List listhoatdong;
		private LibList.List listLoaikhoan;
		private System.Windows.Forms.Button butExcel;
		private System.Windows.Forms.Button butKetthuc;
		private System.Windows.Forms.Button butIn;
		private System.Windows.Forms.Button butXem;
		private LibList.List listchuong;
		private LibList.List listnhombc;
		private System.Windows.Forms.GroupBox grbThang;
		private System.Windows.Forms.ComboBox cboChonthang;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.NumericUpDown numDenthang;
		private System.Windows.Forms.NumericUpDown numTuthang;
		private System.Windows.Forms.NumericUpDown numNam;
		private System.Windows.Forms.Label lblDenthang;
		private System.Windows.Forms.Label lblTuthang;
		private System.Windows.Forms.Label lblNam;
		private System.Windows.Forms.Label lblnguon;
		private System.Windows.Forms.Label lblnhommuc;
		private System.ComponentModel.Container components = null;
		#endregion
		int i_Kieuin=1, i_Banin=1;
		string s_Pagesize="A4";
		private int i_Iduser=0;
		private exportExcel exportExcel=new exportExcel();
		private System.Windows.Forms.GroupBox grbchon;
		private System.Windows.Forms.RadioButton rdb2h;
		private System.Windows.Forms.RadioButton rdb1h;
		private Print_kt Print=new Print_kt();
		
		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmReport_dtns));
            this.panel1 = new System.Windows.Forms.Panel();
            this.pnlButton = new System.Windows.Forms.Panel();
            this.butExcel = new System.Windows.Forms.Button();
            this.butKetthuc = new System.Windows.Forms.Button();
            this.butIn = new System.Windows.Forms.Button();
            this.butXem = new System.Windows.Forms.Button();
            this.grpNen = new System.Windows.Forms.GroupBox();
            this.grbchon = new System.Windows.Forms.GroupBox();
            this.rdb1h = new System.Windows.Forms.RadioButton();
            this.rdb2h = new System.Windows.Forms.RadioButton();
            this.listnhombc = new LibList.List();
            this.listNguon = new LibList.List();
            this.txtTenNguonGoc = new txtListBox.txtListBox();
            this.txtNguonGoc = new txtListBox.txtListBox();
            this.lblnguon = new System.Windows.Forms.Label();
            this.listNhomMuc = new LibList.List();
            this.txtTenNhomMuc = new txtListBox.txtListBox();
            this.txtNhomMuc = new txtListBox.txtListBox();
            this.txttenhoatdong = new System.Windows.Forms.TextBox();
            this.txthoatdong = new System.Windows.Forms.TextBox();
            this.listchuong = new LibList.List();
            this.txttenchuong = new System.Windows.Forms.TextBox();
            this.txtchuong = new System.Windows.Forms.TextBox();
            this.txtnhombc = new System.Windows.Forms.TextBox();
            this.txttennhombc = new System.Windows.Forms.TextBox();
            this.lblnhommuc = new System.Windows.Forms.Label();
            this.txtTenloaikhoan = new txtListBox.txtListBox();
            this.txtLoaikhoan = new txtListBox.txtListBox();
            this.lblnhombc = new System.Windows.Forms.Label();
            this.txtSotaikhoan = new txtListBox.txtListBox();
            this.lblChuong = new System.Windows.Forms.Label();
            this.lblHoatDong = new System.Windows.Forms.Label();
            this.lblLoaikhoan = new System.Windows.Forms.Label();
            this.txtTentaikhoan = new txtListBox.txtListBox();
            this.lblTaikhoan = new System.Windows.Forms.Label();
            this.listTaikhoan = new LibList.List();
            this.listLoaikhoan = new LibList.List();
            this.listhoatdong = new LibList.List();
            this.grbThang = new System.Windows.Forms.GroupBox();
            this.cboChonthang = new System.Windows.Forms.ComboBox();
            this.label1 = new System.Windows.Forms.Label();
            this.numDenthang = new System.Windows.Forms.NumericUpDown();
            this.numTuthang = new System.Windows.Forms.NumericUpDown();
            this.numNam = new System.Windows.Forms.NumericUpDown();
            this.lblDenthang = new System.Windows.Forms.Label();
            this.lblTuthang = new System.Windows.Forms.Label();
            this.lblNam = new System.Windows.Forms.Label();
            this.panel1.SuspendLayout();
            this.pnlButton.SuspendLayout();
            this.grpNen.SuspendLayout();
            this.grbchon.SuspendLayout();
            this.grbThang.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.numDenthang)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.numTuthang)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.numNam)).BeginInit();
            this.SuspendLayout();
            // 
            // panel1
            // 
            this.panel1.Controls.Add(this.pnlButton);
            this.panel1.Controls.Add(this.grpNen);
            this.panel1.Controls.Add(this.grbThang);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panel1.Location = new System.Drawing.Point(0, 0);
            this.panel1.Name = "panel1";
            this.panel1.Padding = new System.Windows.Forms.Padding(5);
            this.panel1.Size = new System.Drawing.Size(488, 312);
            this.panel1.TabIndex = 0;
            // 
            // pnlButton
            // 
            this.pnlButton.Controls.Add(this.butExcel);
            this.pnlButton.Controls.Add(this.butKetthuc);
            this.pnlButton.Controls.Add(this.butIn);
            this.pnlButton.Controls.Add(this.butXem);
            this.pnlButton.Dock = System.Windows.Forms.DockStyle.Fill;
            this.pnlButton.Location = new System.Drawing.Point(5, 272);
            this.pnlButton.Name = "pnlButton";
            this.pnlButton.Size = new System.Drawing.Size(478, 35);
            this.pnlButton.TabIndex = 179;
            // 
            // butExcel
            // 
            this.butExcel.BackColor = System.Drawing.SystemColors.Control;
            this.butExcel.ForeColor = System.Drawing.SystemColors.WindowText;
            this.butExcel.Image = ((System.Drawing.Image)(resources.GetObject("butExcel.Image")));
            this.butExcel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butExcel.Location = new System.Drawing.Point(170, 8);
            this.butExcel.Name = "butExcel";
            this.butExcel.Size = new System.Drawing.Size(68, 25);
            this.butExcel.TabIndex = 187;
            this.butExcel.Text = "     &Excel";
            this.butExcel.UseVisualStyleBackColor = false;
            this.butExcel.Click += new System.EventHandler(this.butExcel_Click);
            // 
            // butKetthuc
            // 
            this.butKetthuc.BackColor = System.Drawing.SystemColors.Control;
            this.butKetthuc.ForeColor = System.Drawing.SystemColors.WindowText;
            this.butKetthuc.Image = ((System.Drawing.Image)(resources.GetObject("butKetthuc.Image")));
            this.butKetthuc.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butKetthuc.Location = new System.Drawing.Point(310, 8);
            this.butKetthuc.Name = "butKetthuc";
            this.butKetthuc.Size = new System.Drawing.Size(68, 25);
            this.butKetthuc.TabIndex = 189;
            this.butKetthuc.Text = "&Kết thúc";
            this.butKetthuc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.butKetthuc.UseVisualStyleBackColor = false;
            this.butKetthuc.Click += new System.EventHandler(this.butKetthuc_Click);
            // 
            // butIn
            // 
            this.butIn.BackColor = System.Drawing.SystemColors.Control;
            this.butIn.ForeColor = System.Drawing.SystemColors.WindowText;
            this.butIn.Image = ((System.Drawing.Image)(resources.GetObject("butIn.Image")));
            this.butIn.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butIn.Location = new System.Drawing.Point(240, 8);
            this.butIn.Name = "butIn";
            this.butIn.Size = new System.Drawing.Size(68, 25);
            this.butIn.TabIndex = 188;
            this.butIn.Text = "     &In";
            this.butIn.UseVisualStyleBackColor = false;
            this.butIn.Click += new System.EventHandler(this.butIn_Click);
            // 
            // butXem
            // 
            this.butXem.BackColor = System.Drawing.SystemColors.Control;
            this.butXem.ForeColor = System.Drawing.SystemColors.WindowText;
            this.butXem.Image = ((System.Drawing.Image)(resources.GetObject("butXem.Image")));
            this.butXem.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butXem.Location = new System.Drawing.Point(100, 8);
            this.butXem.Name = "butXem";
            this.butXem.Size = new System.Drawing.Size(68, 25);
            this.butXem.TabIndex = 186;
            this.butXem.Text = "     &Xem";
            this.butXem.UseVisualStyleBackColor = false;
            this.butXem.Click += new System.EventHandler(this.butXem_Click);
            // 
            // grpNen
            // 
            this.grpNen.BackColor = System.Drawing.SystemColors.Control;
            this.grpNen.Controls.Add(this.grbchon);
            this.grpNen.Controls.Add(this.listnhombc);
            this.grpNen.Controls.Add(this.listNguon);
            this.grpNen.Controls.Add(this.txtTenNguonGoc);
            this.grpNen.Controls.Add(this.txtNguonGoc);
            this.grpNen.Controls.Add(this.lblnguon);
            this.grpNen.Controls.Add(this.listNhomMuc);
            this.grpNen.Controls.Add(this.txtTenNhomMuc);
            this.grpNen.Controls.Add(this.txtNhomMuc);
            this.grpNen.Controls.Add(this.txthoatdong);
            this.grpNen.Controls.Add(this.listchuong);
            this.grpNen.Controls.Add(this.txttenchuong);
            this.grpNen.Controls.Add(this.txtchuong);
            this.grpNen.Controls.Add(this.txtnhombc);
            this.grpNen.Controls.Add(this.txttennhombc);
            this.grpNen.Controls.Add(this.lblnhommuc);
            this.grpNen.Controls.Add(this.txtLoaikhoan);
            this.grpNen.Controls.Add(this.lblnhombc);
            this.grpNen.Controls.Add(this.txtSotaikhoan);
            this.grpNen.Controls.Add(this.lblChuong);
            this.grpNen.Controls.Add(this.lblHoatDong);
            this.grpNen.Controls.Add(this.lblLoaikhoan);
            this.grpNen.Controls.Add(this.lblTaikhoan);
            this.grpNen.Controls.Add(this.listTaikhoan);
            this.grpNen.Controls.Add(this.listLoaikhoan);
            this.grpNen.Controls.Add(this.listhoatdong);
            this.grpNen.Controls.Add(this.txtTentaikhoan);
            this.grpNen.Controls.Add(this.txttenhoatdong);
            this.grpNen.Controls.Add(this.txtTenloaikhoan);
            this.grpNen.Dock = System.Windows.Forms.DockStyle.Top;
            this.grpNen.Location = new System.Drawing.Point(5, 48);
            this.grpNen.Name = "grpNen";
            this.grpNen.Size = new System.Drawing.Size(478, 224);
            this.grpNen.TabIndex = 174;
            this.grpNen.TabStop = false;
            // 
            // grbchon
            // 
            this.grbchon.Controls.Add(this.rdb1h);
            this.grbchon.Controls.Add(this.rdb2h);
            this.grbchon.Location = new System.Drawing.Point(96, 184);
            this.grbchon.Name = "grbchon";
            this.grbchon.Size = new System.Drawing.Size(160, 34);
            this.grbchon.TabIndex = 187;
            this.grbchon.TabStop = false;
            // 
            // rdb1h
            // 
            this.rdb1h.Location = new System.Drawing.Point(96, 8);
            this.rdb1h.Name = "rdb1h";
            this.rdb1h.Size = new System.Drawing.Size(60, 16);
            this.rdb1h.TabIndex = 1;
            this.rdb1h.Text = "F02-1H";
            // 
            // rdb2h
            // 
            this.rdb2h.Location = new System.Drawing.Point(8, 8);
            this.rdb2h.Name = "rdb2h";
            this.rdb2h.Size = new System.Drawing.Size(72, 16);
            this.rdb2h.TabIndex = 0;
            this.rdb2h.Text = "F02-2H";
            // 
            // listnhombc
            // 
            this.listnhombc.BackColor = System.Drawing.SystemColors.Info;
            this.listnhombc.ColumnCount = 0;
            this.listnhombc.Location = new System.Drawing.Point(160, 40);
            this.listnhombc.MatchBufferTimeOut = 1000;
            this.listnhombc.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listnhombc.Name = "listnhombc";
            this.listnhombc.Size = new System.Drawing.Size(80, 17);
            this.listnhombc.TabIndex = 186;
            this.listnhombc.TextIndex = -1;
            this.listnhombc.TextMember = null;
            this.listnhombc.ValueIndex = -1;
            this.listnhombc.Visible = false;
            // 
            // listNguon
            // 
            this.listNguon.BackColor = System.Drawing.SystemColors.Info;
            this.listNguon.ColumnCount = 0;
            this.listNguon.Location = new System.Drawing.Point(160, 136);
            this.listNguon.MatchBufferTimeOut = 1000;
            this.listNguon.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listNguon.Name = "listNguon";
            this.listNguon.Size = new System.Drawing.Size(80, 17);
            this.listNguon.TabIndex = 165;
            this.listNguon.TextIndex = -1;
            this.listNguon.TextMember = null;
            this.listNguon.ValueIndex = -1;
            this.listNguon.Visible = false;
            // 
            // txtTenNguonGoc
            // 
            this.txtTenNguonGoc.BackColor = System.Drawing.SystemColors.Window;
            this.txtTenNguonGoc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtTenNguonGoc.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtTenNguonGoc.Location = new System.Drawing.Point(160, 136);
            this.txtTenNguonGoc.Name = "txtTenNguonGoc";
            this.txtTenNguonGoc.ReadOnly = true;
            this.txtTenNguonGoc.Size = new System.Drawing.Size(304, 21);
            this.txtTenNguonGoc.TabIndex = 42;
            this.txtTenNguonGoc.TabStop = false;
            this.txtTenNguonGoc.Enter += new System.EventHandler(this.txtTenNguonGoc_Enter);
            // 
            // txtNguonGoc
            // 
            this.txtNguonGoc.BackColor = System.Drawing.SystemColors.Window;
            this.txtNguonGoc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtNguonGoc.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtNguonGoc.Location = new System.Drawing.Point(96, 136);
            this.txtNguonGoc.Name = "txtNguonGoc";
            this.txtNguonGoc.Size = new System.Drawing.Size(63, 21);
            this.txtNguonGoc.TabIndex = 41;
            this.txtNguonGoc.DoubleClick += new System.EventHandler(this.txtNguonGoc_DoubleClick);
            this.txtNguonGoc.TextChanged += new System.EventHandler(this.txtNguonGoc_TextChanged);
            this.txtNguonGoc.Validated += new System.EventHandler(this.txtNguonGoc_Validated);
            this.txtNguonGoc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtNguonGoc_KeyDown);
            this.txtNguonGoc.Enter += new System.EventHandler(this.txtNguonGoc_Enter);
            // 
            // lblnguon
            // 
            this.lblnguon.BackColor = System.Drawing.SystemColors.Control;
            this.lblnguon.ForeColor = System.Drawing.Color.DarkBlue;
            this.lblnguon.Location = new System.Drawing.Point(24, 135);
            this.lblnguon.Name = "lblnguon";
            this.lblnguon.Size = new System.Drawing.Size(72, 23);
            this.lblnguon.TabIndex = 164;
            this.lblnguon.Text = "Nguồn :";
            this.lblnguon.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // listNhomMuc
            // 
            this.listNhomMuc.BackColor = System.Drawing.SystemColors.Info;
            this.listNhomMuc.ColumnCount = 0;
            this.listNhomMuc.Location = new System.Drawing.Point(160, 160);
            this.listNhomMuc.MatchBufferTimeOut = 1000;
            this.listNhomMuc.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listNhomMuc.Name = "listNhomMuc";
            this.listNhomMuc.Size = new System.Drawing.Size(80, 17);
            this.listNhomMuc.TabIndex = 160;
            this.listNhomMuc.TextIndex = -1;
            this.listNhomMuc.TextMember = null;
            this.listNhomMuc.ValueIndex = -1;
            this.listNhomMuc.Visible = false;
            // 
            // txtTenNhomMuc
            // 
            this.txtTenNhomMuc.BackColor = System.Drawing.SystemColors.Window;
            this.txtTenNhomMuc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtTenNhomMuc.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtTenNhomMuc.Location = new System.Drawing.Point(160, 160);
            this.txtTenNhomMuc.Name = "txtTenNhomMuc";
            this.txtTenNhomMuc.ReadOnly = true;
            this.txtTenNhomMuc.Size = new System.Drawing.Size(304, 21);
            this.txtTenNhomMuc.TabIndex = 44;
            this.txtTenNhomMuc.TabStop = false;
            // 
            // txtNhomMuc
            // 
            this.txtNhomMuc.BackColor = System.Drawing.SystemColors.Window;
            this.txtNhomMuc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtNhomMuc.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtNhomMuc.Location = new System.Drawing.Point(96, 160);
            this.txtNhomMuc.Name = "txtNhomMuc";
            this.txtNhomMuc.Size = new System.Drawing.Size(63, 21);
            this.txtNhomMuc.TabIndex = 43;
            this.txtNhomMuc.DoubleClick += new System.EventHandler(this.txtNhomMuc_DoubleClick);
            this.txtNhomMuc.TextChanged += new System.EventHandler(this.txtNhomMuc_TextChanged);
            this.txtNhomMuc.Validated += new System.EventHandler(this.txtNhomMuc_Validated);
            this.txtNhomMuc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtNhomMuc_KeyDown);
            this.txtNhomMuc.Enter += new System.EventHandler(this.txtNhomMuc_Enter);
            // 
            // txttenhoatdong
            // 
            this.txttenhoatdong.ForeColor = System.Drawing.Color.DarkBlue;
            this.txttenhoatdong.Location = new System.Drawing.Point(160, 88);
            this.txttenhoatdong.Name = "txttenhoatdong";
            this.txttenhoatdong.Size = new System.Drawing.Size(304, 20);
            this.txttenhoatdong.TabIndex = 38;
            this.txttenhoatdong.Leave += new System.EventHandler(this.txttenhoatdong_Leave);
            this.txttenhoatdong.Enter += new System.EventHandler(this.txttenhoatdong_Enter);
            // 
            // txthoatdong
            // 
            this.txthoatdong.ForeColor = System.Drawing.Color.DarkBlue;
            this.txthoatdong.Location = new System.Drawing.Point(96, 88);
            this.txthoatdong.Name = "txthoatdong";
            this.txthoatdong.Size = new System.Drawing.Size(63, 20);
            this.txthoatdong.TabIndex = 37;
            this.txthoatdong.DoubleClick += new System.EventHandler(this.txthoatdong_DoubleClick);
            this.txthoatdong.TextChanged += new System.EventHandler(this.txthoatdong_TextChanged);
            this.txthoatdong.Validated += new System.EventHandler(this.txthoatdong_Validated);
            this.txthoatdong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txthoatdong_KeyDown);
            this.txthoatdong.Leave += new System.EventHandler(this.txthoatdong_Leave);
            this.txthoatdong.Enter += new System.EventHandler(this.txthoatdong_Enter);
            // 
            // listchuong
            // 
            this.listchuong.BackColor = System.Drawing.SystemColors.Info;
            this.listchuong.ColumnCount = 0;
            this.listchuong.Location = new System.Drawing.Point(160, 64);
            this.listchuong.MatchBufferTimeOut = 1000;
            this.listchuong.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listchuong.Name = "listchuong";
            this.listchuong.Size = new System.Drawing.Size(80, 17);
            this.listchuong.TabIndex = 153;
            this.listchuong.TextIndex = -1;
            this.listchuong.TextMember = null;
            this.listchuong.ValueIndex = -1;
            this.listchuong.Visible = false;
            // 
            // txttenchuong
            // 
            this.txttenchuong.ForeColor = System.Drawing.Color.DarkBlue;
            this.txttenchuong.Location = new System.Drawing.Point(160, 64);
            this.txttenchuong.Name = "txttenchuong";
            this.txttenchuong.Size = new System.Drawing.Size(304, 20);
            this.txttenchuong.TabIndex = 36;
            this.txttenchuong.Leave += new System.EventHandler(this.txttenchuong_Leave);
            this.txttenchuong.Enter += new System.EventHandler(this.txttenchuong_Enter);
            // 
            // txtchuong
            // 
            this.txtchuong.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtchuong.Location = new System.Drawing.Point(96, 64);
            this.txtchuong.Name = "txtchuong";
            this.txtchuong.Size = new System.Drawing.Size(63, 20);
            this.txtchuong.TabIndex = 35;
            this.txtchuong.DoubleClick += new System.EventHandler(this.txtchuong_DoubleClick);
            this.txtchuong.TextChanged += new System.EventHandler(this.txtchuong_TextChanged);
            this.txtchuong.Validated += new System.EventHandler(this.txtchuong_Validated);
            this.txtchuong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtchuong_KeyDown);
            this.txtchuong.Leave += new System.EventHandler(this.txtchuong_Leave);
            this.txtchuong.Enter += new System.EventHandler(this.txtchuong_Enter);
            // 
            // txtnhombc
            // 
            this.txtnhombc.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtnhombc.Location = new System.Drawing.Point(96, 40);
            this.txtnhombc.Name = "txtnhombc";
            this.txtnhombc.Size = new System.Drawing.Size(63, 20);
            this.txtnhombc.TabIndex = 33;
            this.txtnhombc.DoubleClick += new System.EventHandler(this.txtnhombc_DoubleClick);
            this.txtnhombc.TextChanged += new System.EventHandler(this.txtnhombc_TextChanged);
            this.txtnhombc.Validated += new System.EventHandler(this.txtnhombc_Validated);
            this.txtnhombc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtnhombc_KeyDown);
            this.txtnhombc.Leave += new System.EventHandler(this.txtnhombc_Leave);
            this.txtnhombc.Enter += new System.EventHandler(this.txtnhombc_Enter);
            // 
            // txttennhombc
            // 
            this.txttennhombc.ForeColor = System.Drawing.Color.DarkBlue;
            this.txttennhombc.Location = new System.Drawing.Point(160, 40);
            this.txttennhombc.Name = "txttennhombc";
            this.txttennhombc.Size = new System.Drawing.Size(304, 20);
            this.txttennhombc.TabIndex = 34;
            this.txttennhombc.Leave += new System.EventHandler(this.txttennhombc_Leave);
            this.txttennhombc.Enter += new System.EventHandler(this.txttennhombc_Enter);
            // 
            // lblnhommuc
            // 
            this.lblnhommuc.BackColor = System.Drawing.SystemColors.Control;
            this.lblnhommuc.ForeColor = System.Drawing.Color.DarkBlue;
            this.lblnhommuc.Location = new System.Drawing.Point(8, 160);
            this.lblnhommuc.Name = "lblnhommuc";
            this.lblnhommuc.Size = new System.Drawing.Size(88, 23);
            this.lblnhommuc.TabIndex = 144;
            this.lblnhommuc.Text = "Nhóm mục :";
            this.lblnhommuc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // txtTenloaikhoan
            // 
            this.txtTenloaikhoan.BackColor = System.Drawing.SystemColors.Window;
            this.txtTenloaikhoan.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtTenloaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtTenloaikhoan.Location = new System.Drawing.Point(160, 112);
            this.txtTenloaikhoan.Name = "txtTenloaikhoan";
            this.txtTenloaikhoan.ReadOnly = true;
            this.txtTenloaikhoan.Size = new System.Drawing.Size(304, 21);
            this.txtTenloaikhoan.TabIndex = 40;
            this.txtTenloaikhoan.TabStop = false;
            this.txtTenloaikhoan.Enter += new System.EventHandler(this.txtTenloaikhoan_Enter);
            // 
            // txtLoaikhoan
            // 
            this.txtLoaikhoan.BackColor = System.Drawing.SystemColors.Window;
            this.txtLoaikhoan.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtLoaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtLoaikhoan.Location = new System.Drawing.Point(96, 112);
            this.txtLoaikhoan.Name = "txtLoaikhoan";
            this.txtLoaikhoan.Size = new System.Drawing.Size(63, 21);
            this.txtLoaikhoan.TabIndex = 39;
            this.txtLoaikhoan.DoubleClick += new System.EventHandler(this.txtLoaikhoan_DoubleClick);
            this.txtLoaikhoan.TextChanged += new System.EventHandler(this.txtLoaikhoan_TextChanged);
            this.txtLoaikhoan.Validated += new System.EventHandler(this.txtLoaikhoan_Validated);
            this.txtLoaikhoan.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtLoaikhoan_KeyDown);
            this.txtLoaikhoan.Enter += new System.EventHandler(this.txtLoaikhoan_Enter);
            // 
            // lblnhombc
            // 
            this.lblnhombc.BackColor = System.Drawing.SystemColors.Control;
            this.lblnhombc.ForeColor = System.Drawing.Color.DarkBlue;
            this.lblnhombc.Location = new System.Drawing.Point(8, 39);
            this.lblnhombc.Name = "lblnhombc";
            this.lblnhombc.Size = new System.Drawing.Size(88, 23);
            this.lblnhombc.TabIndex = 126;
            this.lblnhombc.Text = "Nhóm báo cáo:";
            this.lblnhombc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // txtSotaikhoan
            // 
            this.txtSotaikhoan.BackColor = System.Drawing.SystemColors.Window;
            this.txtSotaikhoan.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtSotaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtSotaikhoan.Location = new System.Drawing.Point(96, 17);
            this.txtSotaikhoan.Name = "txtSotaikhoan";
            this.txtSotaikhoan.Size = new System.Drawing.Size(63, 21);
            this.txtSotaikhoan.TabIndex = 31;
            this.txtSotaikhoan.DoubleClick += new System.EventHandler(this.txtSotaikhoan_DoubleClick);
            this.txtSotaikhoan.TextChanged += new System.EventHandler(this.txtSotaikhoan_TextChanged);
            this.txtSotaikhoan.Validated += new System.EventHandler(this.txtSotaikhoan_Validated);
            this.txtSotaikhoan.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtSotaikhoan_KeyDown);
            // 
            // lblChuong
            // 
            this.lblChuong.BackColor = System.Drawing.SystemColors.Control;
            this.lblChuong.ForeColor = System.Drawing.Color.DarkBlue;
            this.lblChuong.Location = new System.Drawing.Point(16, 63);
            this.lblChuong.Name = "lblChuong";
            this.lblChuong.Size = new System.Drawing.Size(80, 23);
            this.lblChuong.TabIndex = 137;
            this.lblChuong.Text = "Chương:";
            this.lblChuong.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblHoatDong
            // 
            this.lblHoatDong.BackColor = System.Drawing.SystemColors.Control;
            this.lblHoatDong.ForeColor = System.Drawing.Color.DarkBlue;
            this.lblHoatDong.Location = new System.Drawing.Point(16, 87);
            this.lblHoatDong.Name = "lblHoatDong";
            this.lblHoatDong.Size = new System.Drawing.Size(80, 23);
            this.lblHoatDong.TabIndex = 138;
            this.lblHoatDong.Text = "Hoạt động:";
            this.lblHoatDong.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblLoaikhoan
            // 
            this.lblLoaikhoan.BackColor = System.Drawing.SystemColors.Control;
            this.lblLoaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
            this.lblLoaikhoan.Location = new System.Drawing.Point(24, 111);
            this.lblLoaikhoan.Name = "lblLoaikhoan";
            this.lblLoaikhoan.Size = new System.Drawing.Size(72, 23);
            this.lblLoaikhoan.TabIndex = 33;
            this.lblLoaikhoan.Text = "Loại khoản :";
            this.lblLoaikhoan.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // txtTentaikhoan
            // 
            this.txtTentaikhoan.BackColor = System.Drawing.SystemColors.Window;
            this.txtTentaikhoan.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtTentaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
            this.txtTentaikhoan.Location = new System.Drawing.Point(160, 17);
            this.txtTentaikhoan.Name = "txtTentaikhoan";
            this.txtTentaikhoan.ReadOnly = true;
            this.txtTentaikhoan.Size = new System.Drawing.Size(304, 21);
            this.txtTentaikhoan.TabIndex = 32;
            this.txtTentaikhoan.TabStop = false;
            // 
            // lblTaikhoan
            // 
            this.lblTaikhoan.BackColor = System.Drawing.SystemColors.Control;
            this.lblTaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
            this.lblTaikhoan.Location = new System.Drawing.Point(16, 16);
            this.lblTaikhoan.Name = "lblTaikhoan";
            this.lblTaikhoan.Size = new System.Drawing.Size(80, 23);
            this.lblTaikhoan.TabIndex = 30;
            this.lblTaikhoan.Text = "Loại dự toán:";
            this.lblTaikhoan.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // listTaikhoan
            // 
            this.listTaikhoan.BackColor = System.Drawing.SystemColors.Info;
            this.listTaikhoan.ColumnCount = 0;
            this.listTaikhoan.Location = new System.Drawing.Point(160, 17);
            this.listTaikhoan.MatchBufferTimeOut = 1000;
            this.listTaikhoan.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listTaikhoan.Name = "listTaikhoan";
            this.listTaikhoan.Size = new System.Drawing.Size(80, 17);
            this.listTaikhoan.TabIndex = 183;
            this.listTaikhoan.TextIndex = -1;
            this.listTaikhoan.TextMember = null;
            this.listTaikhoan.ValueIndex = -1;
            this.listTaikhoan.Visible = false;
            // 
            // listLoaikhoan
            // 
            this.listLoaikhoan.BackColor = System.Drawing.SystemColors.Info;
            this.listLoaikhoan.ColumnCount = 0;
            this.listLoaikhoan.Location = new System.Drawing.Point(160, 113);
            this.listLoaikhoan.MatchBufferTimeOut = 1000;
            this.listLoaikhoan.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listLoaikhoan.Name = "listLoaikhoan";
            this.listLoaikhoan.Size = new System.Drawing.Size(80, 17);
            this.listLoaikhoan.TabIndex = 184;
            this.listLoaikhoan.TextIndex = -1;
            this.listLoaikhoan.TextMember = null;
            this.listLoaikhoan.ValueIndex = -1;
            this.listLoaikhoan.Visible = false;
            // 
            // listhoatdong
            // 
            this.listhoatdong.BackColor = System.Drawing.SystemColors.Info;
            this.listhoatdong.ColumnCount = 0;
            this.listhoatdong.Location = new System.Drawing.Point(160, 88);
            this.listhoatdong.MatchBufferTimeOut = 1000;
            this.listhoatdong.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.listhoatdong.Name = "listhoatdong";
            this.listhoatdong.Size = new System.Drawing.Size(80, 17);
            this.listhoatdong.TabIndex = 185;
            this.listhoatdong.TextIndex = -1;
            this.listhoatdong.TextMember = null;
            this.listhoatdong.ValueIndex = -1;
            this.listhoatdong.Visible = false;
            // 
            // grbThang
            // 
            this.grbThang.Controls.Add(this.cboChonthang);
            this.grbThang.Controls.Add(this.label1);
            this.grbThang.Controls.Add(this.numDenthang);
            this.grbThang.Controls.Add(this.numTuthang);
            this.grbThang.Controls.Add(this.numNam);
            this.grbThang.Controls.Add(this.lblDenthang);
            this.grbThang.Controls.Add(this.lblTuthang);
            this.grbThang.Controls.Add(this.lblNam);
            this.grbThang.Dock = System.Windows.Forms.DockStyle.Top;
            this.grbThang.Location = new System.Drawing.Point(5, 5);
            this.grbThang.Name = "grbThang";
            this.grbThang.Size = new System.Drawing.Size(478, 43);
            this.grbThang.TabIndex = 178;
            this.grbThang.TabStop = false;
            // 
            // cboChonthang
            // 
            this.cboChonthang.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cboChonthang.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cboChonthang.ForeColor = System.Drawing.Color.DarkBlue;
            this.cboChonthang.ImeMode = System.Windows.Forms.ImeMode.NoControl;
            this.cboChonthang.Items.AddRange(new object[] {
            " Tháng",
            " Quý",
            " Năm"});
            this.cboChonthang.Location = new System.Drawing.Point(96, 16);
            this.cboChonthang.Name = "cboChonthang";
            this.cboChonthang.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.cboChonthang.Size = new System.Drawing.Size(107, 21);
            this.cboChonthang.TabIndex = 19;
            this.cboChonthang.SelectedIndexChanged += new System.EventHandler(this.cboChonthang_SelectedIndexChanged);
            this.cboChonthang.Enter += new System.EventHandler(this.cboChonthang_Enter);
            // 
            // label1
            // 
            this.label1.BackColor = System.Drawing.SystemColors.Control;
            this.label1.ForeColor = System.Drawing.Color.DarkBlue;
            this.label1.Location = new System.Drawing.Point(8, 16);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(80, 23);
            this.label1.TabIndex = 18;
            this.label1.Text = "Báo cáo theo :";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // numDenthang
            // 
            this.numDenthang.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.numDenthang.ForeColor = System.Drawing.Color.DarkBlue;
            this.numDenthang.Location = new System.Drawing.Point(336, 16);
            this.numDenthang.Maximum = new decimal(new int[] {
            12,
            0,
            0,
            0});
            this.numDenthang.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.numDenthang.Name = "numDenthang";
            this.numDenthang.Size = new System.Drawing.Size(38, 21);
            this.numDenthang.TabIndex = 24;
            this.numDenthang.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.numDenthang.Enter += new System.EventHandler(this.numDenthang_Enter);
            // 
            // numTuthang
            // 
            this.numTuthang.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.numTuthang.ForeColor = System.Drawing.Color.DarkBlue;
            this.numTuthang.Location = new System.Drawing.Point(264, 16);
            this.numTuthang.Maximum = new decimal(new int[] {
            12,
            0,
            0,
            0});
            this.numTuthang.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.numTuthang.Name = "numTuthang";
            this.numTuthang.Size = new System.Drawing.Size(38, 21);
            this.numTuthang.TabIndex = 21;
            this.numTuthang.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.numTuthang.Enter += new System.EventHandler(this.numTuthang_Enter);
            // 
            // numNam
            // 
            this.numNam.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.numNam.ForeColor = System.Drawing.Color.DarkBlue;
            this.numNam.Location = new System.Drawing.Point(416, 16);
            this.numNam.Maximum = new decimal(new int[] {
            3004,
            0,
            0,
            0});
            this.numNam.Minimum = new decimal(new int[] {
            2004,
            0,
            0,
            0});
            this.numNam.Name = "numNam";
            this.numNam.Size = new System.Drawing.Size(48, 21);
            this.numNam.TabIndex = 25;
            this.numNam.Value = new decimal(new int[] {
            2004,
            0,
            0,
            0});
            this.numNam.Enter += new System.EventHandler(this.numNam_Enter);
            // 
            // lblDenthang
            // 
            this.lblDenthang.BackColor = System.Drawing.SystemColors.Control;
            this.lblDenthang.ForeColor = System.Drawing.Color.DarkBlue;
            this.lblDenthang.Location = new System.Drawing.Point(296, 16);
            this.lblDenthang.Name = "lblDenthang";
            this.lblDenthang.Size = new System.Drawing.Size(32, 23);
            this.lblDenthang.TabIndex = 22;
            this.lblDenthang.Text = "đến ";
            this.lblDenthang.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblTuthang
            // 
            this.lblTuthang.BackColor = System.Drawing.SystemColors.Control;
            this.lblTuthang.ForeColor = System.Drawing.Color.DarkBlue;
            this.lblTuthang.Location = new System.Drawing.Point(208, 16);
            this.lblTuthang.Name = "lblTuthang";
            this.lblTuthang.Size = new System.Drawing.Size(49, 23);
            this.lblTuthang.TabIndex = 20;
            this.lblTuthang.Text = "Từ tháng";
            this.lblTuthang.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblNam
            // 
            this.lblNam.BackColor = System.Drawing.SystemColors.Control;
            this.lblNam.ForeColor = System.Drawing.Color.DarkBlue;
            this.lblNam.Location = new System.Drawing.Point(376, 16);
            this.lblNam.Name = "lblNam";
            this.lblNam.Size = new System.Drawing.Size(34, 23);
            this.lblNam.TabIndex = 23;
            this.lblNam.Text = "năm";
            this.lblNam.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // frmReport_dtns
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(488, 312);
            this.Controls.Add(this.panel1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "frmReport_dtns";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Load += new System.EventHandler(this.frmReport_dtns_Load);
            this.panel1.ResumeLayout(false);
            this.pnlButton.ResumeLayout(false);
            this.grpNen.ResumeLayout(false);
            this.grpNen.PerformLayout();
            this.grbchon.ResumeLayout(false);
            this.grbThang.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.numDenthang)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.numTuthang)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.numNam)).EndInit();
            this.ResumeLayout(false);

		}
		#endregion		

		#region Constructor
		public frmReport_dtns(string s_Form,AccessData acc,int i_iduser)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			a=acc;
			s_Tenform=s_Form;
			i_Iduser=i_iduser;
			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}
		#endregion
        
		#region Destructor
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
			try
			{
				a.Dispose();
				dtDmtk.Dispose();
				dtDmlk.Dispose();				
				ds_Data.Dispose();
			}
			catch
			{}
		}
		#endregion

		#region Variables
		//Khai bao gia tri mau cho form
		private int i_Red=255,i_Green=255,i_Blue=195;
		//private bool kt_chon_da=false;
		private bool kt_chon_kp=false,b_form=false;
		private AccessData a;
		//Khai bao bien su dung trong form.
		private string s_Tenform="";
		private int i_HTaikhoan=0,i_HLoaikhoan=0;		
		private DataRow r;
		private System.Data.DataTable dtDmtk,dtDmlk,dtDmnhombc,dtDmChuong,dtDmHoatdong,dtDmNhomMuc,dtDmNguon;
		private DataSet ds_Data;
//		private DataSet ds=new DataSet();
		string ngaythangnam="",text="",chuky1="";
		private string s_Report="",s_loaidutoan="",s_loai="",s_khoan="",s_nhommuc="",ngayin="";		
		private bool b_Nguon = true;
//		Excel.Application oxl;
//		Excel._Workbook owb;
//		Excel._Worksheet osheet;
		#endregion
		
		#region Load Form
		private void frmReport_dtns_Load(object sender, System.EventArgs e)
		{
			grbchon.Visible=false;
			cboChonthang.SelectedIndex=0;
			numTuthang.Maximum=12; numTuthang.Minimum=1;
			numDenthang.Maximum=12; numDenthang.Minimum=1;
			numTuthang.Value=DateTime.Now.Month;
			numDenthang.Value=DateTime.Now.Month;
			numNam.Value=DateTime.Now.Year;
			ngayin = "Ngày " + DateTime.Now.Day.ToString() + " tháng ";
			ngayin += DateTime.Now.Month + " năm " + DateTime.Now.Year.ToString();
			f_Loadform();
			f_Loaddm();			
		}
		#endregion

		#region Control Events
		
		#region Button Events
		private void butXem_Click(object sender, System.EventArgs e)
		{
			if(s_Tenform=="GiaoDuToan" || s_Tenform=="dutoan_nskhobac")
			{
				Display(1);
			}
			
			if(s_Tenform=="NhanDuToan" || s_Tenform=="tc_CTkinhphihoatdong" || s_Tenform=="tc_CTkinhphiduan" || s_Tenform=="tc_mKPI" || s_Tenform=="tc_mKPI_longan" || s_Tenform=="TamungKP_KhoBac"||s_Tenform=="TamungKP_KhoBac_TM")
			{
				Display_(1);
			}			
		}	

		private void butExcel_Click(object sender, System.EventArgs e)
		{
			Display_(2);
			
		}

		private void butIn_Click(object sender, System.EventArgs e)
		{
			if(s_Tenform=="GiaoDuToan")
			{
				Display(3);
			}
			
			if(s_Tenform=="NhanDuToan")
			{
				Display_(3);
			}
		}

		private void butKetthuc_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
		#endregion		

		#region Numeric Events
		private void numTuthang_Enter(object sender, System.EventArgs e)
		{
			this.numTuthang.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void numDenthang_Enter(object sender, System.EventArgs e)
		{
			this.numDenthang.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void numNam_Enter(object sender, System.EventArgs e)
		{
			this.numNam.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}
	
		private void cboChonthang_Enter(object sender, System.EventArgs e)
		{
			this.cboChonthang.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}
		#endregion		
		
		#region Textbox Events
		//TAI KHOAN - DU TOAN
		private void txtSotaikhoan_DoubleClick(object sender, System.EventArgs e)
		{
			listTaikhoan.Focus();
			Filter_List(txtSotaikhoan.Text,1);
			listTaikhoan.BrowseToDmtk(txtSotaikhoan,txtTentaikhoan,txtnhombc,txtchuong.Location.X,txtSotaikhoan.Location.Y+15,txtSotaikhoan.Width+0+txtTentaikhoan.Width,txtSotaikhoan.Height+i_HTaikhoan,100);
		}

		private void txtSotaikhoan_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listTaikhoan.Focus();
			else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
			{
				if (listTaikhoan.Visible) listTaikhoan.Focus();
				else SendKeys.Send("{Tab}");
			}
		}

		private void txtSotaikhoan_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtSotaikhoan)
			{
				Filter_List(txtSotaikhoan.Text,1);
				listTaikhoan.BrowseToDmtk(txtSotaikhoan,txtTentaikhoan,txtnhombc,txtchuong.Location.X,txtSotaikhoan.Location.Y+15,txtSotaikhoan.Width+0+txtTentaikhoan.Width,txtSotaikhoan.Height+i_HTaikhoan,100);
			}
		}

		private void txtSotaikhoan_Validated(object sender, System.EventArgs e)
		{
			txtTentaikhoan.Text="";
			if (txtSotaikhoan.Text!="")
			{
				r=a.getrowbyid(dtDmtk,"stk='"+txtSotaikhoan.Text.Trim()+"'");
				if (r!=null) 
				{
					txtTentaikhoan.Text=r["ttk"].ToString();
					txtNguonGoc.Text="";txtTenNguonGoc.Text="";b_Nguon=false;
				}
			}
			hide_List();
		}

		//NHOM BAO CAO
		private void txtnhombc_DoubleClick(object sender, System.EventArgs e)
		{	
			listnhombc.Focus();
			Filter_List(txtnhombc.Text,2);
			listnhombc.BrowseToDmtk(txtnhombc,txttennhombc,txtchuong,txtchuong.Location.X,txtnhombc.Location.Y+15,txtnhombc.Width+0+txttennhombc.Width,txtnhombc.Height+i_HTaikhoan,100);
		}

		private void txtnhombc_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listnhombc.Focus();
			else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
			{
				if (listnhombc.Visible) listnhombc.Focus();
				else SendKeys.Send("{Tab}");
			}
		}

		private void txtnhombc_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtnhombc)
			{
				Filter_List(txtnhombc.Text,2);
				listnhombc.BrowseToDmtk(txtnhombc,txttennhombc,txtchuong,txtchuong.Location.X,txtnhombc.Location.Y+15,txtnhombc.Width+0+txttennhombc.Width,txtnhombc.Height+i_HTaikhoan,100);
			}
		}

		private void txtnhombc_Validated(object sender, System.EventArgs e)
		{
			txttennhombc.Text="";
			if (txtnhombc.Text!="")
			{
				r=a.getrowbyid(dtDmnhombc,"ma='"+txtnhombc.Text.Trim()+"'");
				if (r!=null) 
				{
					txttennhombc.Text=r["ten"].ToString();
				}
			}
			hide_List();
		}

		//CHUONG
		private void txtchuong_DoubleClick(object sender, System.EventArgs e)
		{
			listchuong.Focus();
			Filter_List(txtchuong.Text,3);			
			listchuong.BrowseToDmtk(txtchuong,txttenchuong,txthoatdong,txtchuong.Location.X,txtchuong.Location.Y+15,txtchuong.Width+0+txttenchuong.Width,txtchuong.Height+i_HLoaikhoan,100);								
		}

		private void txtchuong_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listchuong.Focus();
			else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
			{
				if (listchuong.Visible) listchuong.Focus();
				else SendKeys.Send("{Tab}");
			}
		}

		private void txtchuong_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtchuong)
			{
				Filter_List(txtchuong.Text,3);			
				listchuong.BrowseToDmtk(txtchuong,txttenchuong,txthoatdong,txtchuong.Location.X,txtchuong.Location.Y+15,txtchuong.Width+0+txttenchuong.Width,txtchuong.Height+i_HLoaikhoan,100);								
			}
		}

		private void txtchuong_Validated(object sender, System.EventArgs e)
		{
			txttenchuong.Text="";
			if (txtchuong.Text!="")
			{
				r=a.getrowbyid(dtDmChuong,"ma='"+txtchuong.Text.Trim()+"'");
				if (r!=null) 
				{
					txttenchuong.Text=r["ten"].ToString();
				}
			}
			hide_List();
		}

		//HOAT DONG
		private void txthoatdong_DoubleClick(object sender, System.EventArgs e)
		{
			listhoatdong.Focus();
			Filter_List(txthoatdong.Text,4);
			listhoatdong.BrowseToDmtk(txthoatdong,txttenhoatdong,txtLoaikhoan,txthoatdong.Location.X,txthoatdong.Location.Y +15,txthoatdong.Width+0+txttenhoatdong.Width,txthoatdong.Height+i_HLoaikhoan,100);							
		}

		private void txthoatdong_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listhoatdong.Focus();
			else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
			{
				if (listhoatdong.Visible) listhoatdong.Focus();
				else SendKeys.Send("{Tab}");
			}
		}

		private void txthoatdong_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txthoatdong)
			{
				Filter_List(txthoatdong.Text,4);
				listhoatdong.BrowseToDmtk(txthoatdong,txttenhoatdong,txtLoaikhoan,txthoatdong.Location.X,txthoatdong.Location.Y +15,txthoatdong.Width+0+txttenhoatdong.Width,txthoatdong.Height+i_HLoaikhoan,100);							
			}
		}

		private void txthoatdong_Validated(object sender, System.EventArgs e)
		{
			txttenhoatdong.Text="";
			if (txthoatdong.Text!="")
			{
				r=a.getrowbyid(dtDmHoatdong,"ma='"+txthoatdong.Text.Trim()+"'");
				if (r!=null) 
				{
					txttenhoatdong.Text=r["ten"].ToString();
					txtNguonGoc.Text="";txtTenNguonGoc.Text="";b_Nguon=false;
				}
			}
				hide_List();
		}

		//LOAI KHOAN
		private void txtLoaikhoan_DoubleClick(object sender, System.EventArgs e)
		{
			listLoaikhoan.Focus();
			Filter_List(txtLoaikhoan.Text,5);			
			listLoaikhoan.BrowseToDmtk(txtLoaikhoan,txtTenloaikhoan,txtNguonGoc,txtLoaikhoan.Location.X,txtLoaikhoan.Location.Y+15,txtLoaikhoan.Width+0+txtTenloaikhoan.Width,txtLoaikhoan.Height+i_HLoaikhoan,100);
		}

		private void txtLoaikhoan_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listLoaikhoan.Focus();
			else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
			{
				if (listLoaikhoan.Visible) listLoaikhoan.Focus();
				else SendKeys.Send("{Tab}");
			}
		}

		private void txtLoaikhoan_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtLoaikhoan)
			{
				Filter_List(txtLoaikhoan.Text,5);			
				listLoaikhoan.BrowseToDmtk(txtLoaikhoan,txtTenloaikhoan,txtNguonGoc,txtLoaikhoan.Location.X,txtLoaikhoan.Location.Y+15,txtLoaikhoan.Width+0+txtTenloaikhoan.Width,txtLoaikhoan.Height+i_HLoaikhoan,100);
			}
		}

		private void txtLoaikhoan_Validated(object sender, System.EventArgs e)
		{
			txtTenloaikhoan.Text="";
			if (txtLoaikhoan.Text!="")
			{
				r=a.getrowbyid(dtDmlk,"lk='"+txtLoaikhoan.Text.Trim()+"'");
				if (r!=null) 
				{
					txtTenloaikhoan.Text=r["tlk"].ToString();
				}
			}
			hide_List();
		}

		//NGUON GOC
		private void txtNguonGoc_DoubleClick(object sender, System.EventArgs e)
		{
			if (dtDmNguon!=null && !b_Nguon)
			{
				listNguon.Focus();
				Filter_List(txtNguonGoc.Text,6);
				listNguon.BrowseToDmtk(txtNguonGoc,txtTenNguonGoc,txtNhomMuc,txtLoaikhoan.Location.X,txtNguonGoc.Location.Y+15,txtNguonGoc.Width+0+txtTenNguonGoc.Width,txtNguonGoc.Height,100);				
			}	
		}

		private void txtNguonGoc_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{	
			if (dtDmNguon!=null && b_Nguon)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listNguon.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listNguon.Visible) 
					{
						listNguon.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtNguonGoc_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtNguonGoc && dtDmNguon!=null && b_Nguon)
			{
				Filter_List(txtNguonGoc.Text,6);
				listNguon.BrowseToDmtk(txtNguonGoc,txtTenNguonGoc,txtNhomMuc,txtLoaikhoan.Location.X,txtNguonGoc.Location.Y+15,txtNguonGoc.Width+0+txtTenNguonGoc.Width,txtNguonGoc.Height,100);				
			}
		}

		private void txtNguonGoc_Validated(object sender, System.EventArgs e)
		{
			if (dtDmNguon!=null && b_Nguon)
			{
				r=a.getrowbyid(dtDmNguon,"mang='"+txtNguonGoc.Text.Trim()+"'");
				if (r!=null) 
				{
					txtTenNguonGoc.Text=r["ten"].ToString();
				}
			}
			hide_List();
		}

		//NHOM MUC
		private void txtNhomMuc_DoubleClick(object sender, System.EventArgs e)
		{
			listNhomMuc.Focus();
			Filter_List(txtNhomMuc.Text,7);
			listNhomMuc.BrowseToDmtk(txtNhomMuc,txtTenNhomMuc,butXem,txtchuong.Location.X,txtNhomMuc.Location.Y+15,txtNhomMuc.Width+0+txtTenNhomMuc.Width,txtNhomMuc.Height+i_HLoaikhoan,100);
			
		}

		private void txtNhomMuc_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{			
			if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listNhomMuc.Focus();
			else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
			{
				if (listNhomMuc.Visible) listNhomMuc.Focus();
				else SendKeys.Send("{Tab}");
			}
		}

		private void txtNhomMuc_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtNhomMuc)
			{
				Filter_List(txtNhomMuc.Text,7);
				listNhomMuc.BrowseToDmtk(txtNhomMuc,txtTenNhomMuc,butXem,txtchuong.Location.X,txtNhomMuc.Location.Y+15,txtNhomMuc.Width+0+txtTenNhomMuc.Width,txtNhomMuc.Height+i_HLoaikhoan,100);
			}	
		}

		private void txtNhomMuc_Validated(object sender, System.EventArgs e)
		{
			txtTenNhomMuc.Text="";
			if (txtNhomMuc.Text!="")
			{
				r=a.getrowbyid(dtDmNhomMuc,"nhom='"+txtNhomMuc.Text.Trim()+"'");
				if (r!=null) 
				{
					txtTenNhomMuc.Text=r["tennhom"].ToString();
				}
			}
			hide_List();
		}
		

		#region  ENTER - LEAVE EVENTS
		private void txtnhombc_Enter(object sender, System.EventArgs e)
		{
			this.txtnhombc.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txttennhombc_Enter(object sender, System.EventArgs e)
		{
			this.txttennhombc.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txtchuong_Enter(object sender, System.EventArgs e)
		{
			this.txtchuong.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txttenchuong_Enter(object sender, System.EventArgs e)
		{
			this.txttenchuong.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txtLoaikhoan_Enter(object sender, System.EventArgs e)
		{
			this.txtLoaikhoan.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txtTenloaikhoan_Enter(object sender, System.EventArgs e)
		{
			this.txtTenloaikhoan.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txtNguonGoc_Enter(object sender, System.EventArgs e)
		{
			try
			{
				string s_IDhoatdong=a.getrowbyid(dtDmHoatdong,"ma='"+txthoatdong.Text.Trim()+"'")["id"].ToString().Trim();
				if (txtSotaikhoan.Text!="" &&s_Tenform!="tc_mKPI")
				{					
					DataRow r=a.getrowbyid(dtDmtk,"stk='"+txtSotaikhoan.Text+"'");
					string sql="";
					if (r!=null)
					{						
						string s_Manguon=txtSotaikhoan.Text.Trim().Split('.')[1].ToString();
						sql="select mang,ten,id from a_dmng where sudung=1 and mang='"+s_Manguon+"' and loaikp='"+s_IDhoatdong+"' order by mang";
						dtDmNguon=a.get_data(sql).Tables[0];
						f_LoadNguon(dtDmNguon);							
						b_Nguon=true;
						
					}
				}
				else
					if(txtSotaikhoan.Text==""&&s_Tenform!="tc_CTkinhphihoatdong"&&s_Tenform!="tc_CTkinhphiduan"&&s_Tenform!="tc_mKPI")
				{
					b_Nguon=false;
					txtNguonGoc.Text="";txtTenNguonGoc.Text="";
					SendKeys.Send("{Tab}");							
				}
				else if(s_Tenform=="tc_CTkinhphiduan" || s_Tenform=="tc_CTkinhphihoatdong" || s_Tenform=="tc_mKPI")
				{
					dtDmNguon=a.get_DMNguon(s_IDhoatdong).Tables[0];
					f_LoadNguon(dtDmNguon);
					b_Nguon=true;
				}
			}
			catch
			{
				b_Nguon=false;							
				SendKeys.Send("{Tab}");
			}
			this.txtNguonGoc.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txtTenNguonGoc_Enter(object sender, System.EventArgs e)
		{
			this.txtTenNguonGoc.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txtNhomMuc_Enter(object sender, System.EventArgs e)
		{
			this.txtNhomMuc.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txtTenNhomMuc_Enter(object sender, System.EventArgs e)
		{
			this.txtTenNhomMuc.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}
		
		private void txtnhombc_Leave(object sender, System.EventArgs e)
		{
			this.txtnhombc.BackColor =Color.White;
		}

		private void txttennhombc_Leave(object sender, System.EventArgs e)
		{
			this.txttennhombc.BackColor =Color.White;
		}

		private void txtchuong_Leave(object sender, System.EventArgs e)
		{
			this.txtchuong.BackColor =Color.White;
		}

		private void txttenchuong_Leave(object sender, System.EventArgs e)
		{
			this.txttenchuong.BackColor =Color.White;
		}
		
		private void txthoatdong_Leave(object sender, System.EventArgs e)
		{
			this.txthoatdong.BackColor =Color.White;
		}

		private void txttenhoatdong_Leave(object sender, System.EventArgs e)
		{
			this.txttenhoatdong.BackColor =Color.White;
		}

		private void txttenhoatdong_Enter(object sender, System.EventArgs e)
		{
			this.txttenhoatdong.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txthoatdong_Enter(object sender, System.EventArgs e)
		{
			this.txthoatdong.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}
		#endregion

		#endregion

		private void cboChonthang_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			try
			{
				switch (cboChonthang.SelectedIndex)
				{
					case 0:
						lblTuthang.Enabled=true; numTuthang.Enabled=true;
						lblDenthang.Enabled=true; numDenthang.Enabled=true;
						lblTuthang.Text="Từ tháng"; lblDenthang.Text="đến";
						numTuthang.Maximum=12; numTuthang.Minimum=1;
						numDenthang.Maximum=12; numDenthang.Minimum=1;
						numTuthang.Value=DateTime.Now.Month;
						numDenthang.Value=DateTime.Now.Month;
						numNam.Value=DateTime.Now.Year;
						
						break;
					case 1:
						lblTuthang.Enabled=false; numTuthang.Enabled=false;
						lblDenthang.Enabled=true; numDenthang.Enabled=true;
						lblTuthang.Text="Từ tháng"; lblDenthang.Text="Quý";
						numTuthang.Maximum=12; numTuthang.Minimum=1;
						numDenthang.Maximum=4; numDenthang.Minimum=1;
						int i_Quy=(int)((int.Parse(DateTime.Now.Month.ToString())-1)/3)+1;
						numDenthang.Value=i_Quy;
						numNam.Value=DateTime.Now.Year;
						
						break;
					case 2:
						lblTuthang.Enabled=false; numTuthang.Enabled=false;
						lblDenthang.Enabled=false; numDenthang.Enabled=false;
						lblTuthang.Text="Từ tháng"; lblDenthang.Text="đến";
						numTuthang.Maximum=12; numTuthang.Minimum=1;
						numDenthang.Maximum=12; numDenthang.Minimum=1;
						numNam.Value=DateTime.Now.Year;						
						break;
					default:
						lblTuthang.Enabled=true; numTuthang.Enabled=true;
						lblDenthang.Enabled=true; numDenthang.Enabled=true;
						lblTuthang.Text="Từ tháng"; lblDenthang.Text="đến";
						numTuthang.Maximum=12; numTuthang.Minimum=1;
						numDenthang.Maximum=12; numDenthang.Minimum=1;
						numTuthang.Focus();
						break;
				}
			}
			catch{}	;
		}

		#endregion

		#region Functions
		private void f_Loadform()
		{
			i_HTaikhoan=2; i_HLoaikhoan=-2;
			switch (s_Tenform)
			{
				case "GiaoDuToan":
					f_Loadform_GiaoDuToan();
					break;
				case "NhanDuToan":
					f_Loadform_GiaoDuToan();
					break;
				case "tc_CTkinhphihoatdong":
					f_Loadform_tc_CTkinhphihoatdong("BÁO CÁO CHI TIẾT KINH PHÍ HOẠT ĐỘNG","KT_tc_CTkinhphihoatdong.rpt");
					break;
				case "tc_CTkinhphiduan":
					f_Loadform_tc_CTkinhphihoatdong("BÁO CÁO CHI TIẾT KINH PHÍ HOẠT ĐỘNG","KT_ChiTietKinhPhiDuAn1.rpt");
					break;				
				case "tc_mKPI":
					f_Loadform_tc_CTkinhphihoatdong("TỔNG HỢP TÌNH HÌNH KINH PHÍ VÀ QUYẾT TOÁN KINH PHÍ ĐÃ SỬ DỤNG I","KT_TongHopTinhHinhKP_QuyetToanKP1.rpt");
					break;	
				case "tc_mKPI_longan":
					f_Loadform_tc_CTkinhphihoatdong("TỔNG HỢP TÌNH HÌNH KINH PHÍ VÀ QUYẾT TOÁN KINH PHÍ ĐÃ SỬ DỤNG I - ĐẶT THÙ THEO BỆNH VIỆN","KT_TongHopTinhHinhKP_QuyetToanKP1_la.rpt");
					break;	
				case "TamungKP_KhoBac":
					f_Loadform_tc_CTkinhphihoatdong("SỔ THEO DÕI TẠM ỨNG KINH PHÍ CỦA KHO BẠC (MẪU SỐ S72-H)","KT_Sotheodoi_tukpkb.rpt");
					break;
				case "dutoan_nskhobac":
					f_Loadform_GiaoDuToan();
					break;					
				case "TamungKP_KhoBac_TM":
					f_Loadform_tc_CTkinhphihoatdong("BẢNG ĐỐI CHIẾU TÌNH HÌNH TẠM ỨNG VÀ THANH TOÁN TẠM ỨNG KINH PHÍ TẠI KHO BẠC NHÀ NƯỚC (MẤU SỐ F02-3aH)","KT_DCTamungThanhToanKPNS_KhoBac.rpt");
					break;
				default:
					f_Loadform_Null();
					break;
			}
		}


		private void f_Loadform_Null()
		{
			try
			{
				this.Text="Báo cáo đang xây dựng!";					
				grpNen.Dispose(); lblChuong.Dispose(); 
				lblTaikhoan.Dispose(); txtSotaikhoan.Dispose(); txtTentaikhoan.Dispose();
				lblLoaikhoan.Dispose(); txtLoaikhoan.Dispose(); txtTenloaikhoan.Dispose();
				lblHoatDong.Dispose();
				lblHoatDong.Dispose();
				butXem.Dispose(); butIn.Dispose(); 						
			}
			catch 
			{
				MessageBox.Show("Có lỗi xảy ra !", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
			}		
			
		}


		private void f_Loadform_GiaoDuToan()
		{
			try
			{
				switch(s_Tenform)
				{
					case "GiaoDuToan":
						this.Text="SỔ THEO DÕI GIAO DỰ TOÁN";	
						s_Report="KT_SoTheoDoiGiaoDuToan.rpt";
						label1.Enabled=false;
						cboChonthang.Enabled=false;
						lblTuthang.Enabled=false;
						numTuthang.Enabled=false;
						lblDenthang.Enabled=false;
						numDenthang.Enabled=false;
						i_HTaikhoan=2; i_HLoaikhoan=-4;	   
						break;
					case "dutoan_nskhobac":
						this.Text="BẢNG ĐỐI CHIẾU DỰ TOÁN KINH PHÍ NGÂN SÁCH TẠI KHO BẠC";	
						s_Report="KT_DCDuToanKPNS_KhoBac.rpt";						   
						break;
					case "NhanDuToan":
						this.Text="SỔ THEO DÕI NHẬN DỰ TOÁN";					          					
						s_Report="KT_SoTheoDoiNhanDuToan.rpt";						
						i_HTaikhoan=2; i_HLoaikhoan=-4;	
						break;
				}			         					
					
			}
			catch 
			{
				MessageBox.Show("Có lỗi xảy ra !", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
			}			
		}
		private void f_Loadform_tc_CTkinhphihoatdong(string tieude,string s_tenReport)
		{						
			this.Text=tieude;
			grbchon.Visible=true;			
			if(s_Tenform!="TamungKP_KhoBac" && s_Tenform!="TamungKP_KhoBac_TM")
			{
				b_form=true;
				lblTaikhoan.Visible=false;
				txtSotaikhoan.Visible=false;
				txtTentaikhoan.Visible=false;
				//dinh lai cac control keo len tren
				lblnhombc.Top=lblTaikhoan.Location.Y;
				txtnhombc.Top=txtSotaikhoan.Location.Y;
				txttennhombc.Top=txtTentaikhoan.Location.Y;

				lblChuong.Top=(lblnhombc.Location.Y)+24;
				txtchuong.Top=(txtnhombc.Location.Y)+24;
				txttenchuong.Top=(txttennhombc.Location.Y)+24;
			
				lblHoatDong.Top=(lblChuong.Location.Y)+24;
				txthoatdong.Top=(txtchuong.Location.Y)+24;
				txttenhoatdong.Top=(txttenchuong.Location.Y)+24;

				lblLoaikhoan.Top=(lblHoatDong.Location.Y)+24;
				txtLoaikhoan.Top=(txthoatdong.Location.Y)+24;
				txtTenloaikhoan.Top=(txttenhoatdong.Location.Y)+24;

				lblnguon.Top=(txtLoaikhoan.Location.Y)+24;
				txtNguonGoc.Top=(txtLoaikhoan.Location.Y)+24;
				txtTenNguonGoc.Top=(txtLoaikhoan.Location.Y)+24;

				lblnhommuc.Top=(lblnguon.Location.Y)+24;
				txtNhomMuc.Top=(txtNguonGoc.Location.Y)+24;
				txtTenNhomMuc.Top=(txtTenNguonGoc.Location.Y)+24;
			}
			//thay nhommuc=muc
			lblnhommuc.Text="Mục";
			grbchon.Top=(lblnhommuc.Location.Y)+24;	
			grpNen.Height=200;
			pnlButton.Top=210;
			this.Height=310;
			if(s_Tenform=="tc_CTkinhphiduan")				
			{
				rdb1h.Checked=true;
			}
			else				
				grbchon.Visible=false;
			//MessageBox.Show(this.text);
			s_Report=s_tenReport;

		}

		/// <summary>
		/// load data vao LIST BOX
		/// </summary>
		private void f_Loaddm()
		{				
			try
			{
				//LOAI DU TOAN
				if(s_Tenform=="dutoan_nskhobac")
					dtDmtk=a.get_DMTaikhoan("008").Tables[0];					
				else if(s_Tenform=="TamungKP_KhoBac" || s_Tenform=="TamungKP_KhoBac_TM") 
					dtDmtk=a.get_DMTaikhoan("336","461").Tables[0];
				else dtDmtk=a.get_DMDuToan().Tables[0];	
				listTaikhoan.TextMember="stk";
				listTaikhoan.DisplayMember="ttk";
				listTaikhoan.ValueMember="ttk";
				listTaikhoan.DataSource=dtDmtk;	
				
				// listbox NHOM BAO CAO
				dtDmnhombc=a.get_DMNhombc().Tables[0];		
				listnhombc.TextMember="ma";
				listnhombc.DisplayMember="ten";
				listnhombc.ValueMember="ten";
				listnhombc.DataSource=dtDmnhombc;
				//listbox CHUONG
				dtDmChuong=a.get_DMChuong().Tables[0];
				listchuong.TextMember="ma";
				listchuong.DisplayMember="ten";
				listchuong.ValueMember="ten";
				listchuong.DataSource=dtDmChuong;
				
				//load LOAI KHOAN
				dtDmlk=a.get_DMLoaikhoan().Tables[0];
				listLoaikhoan.TextMember="lk";
				listLoaikhoan.DisplayMember="tlk";
				listLoaikhoan.ValueMember="tlk";
				listLoaikhoan.DataSource=dtDmlk;

				//HOAT DONG
				dtDmHoatdong=a.get_DMHoatdong("").Tables[0];

				// load NHOM MUC
				if(s_Tenform!="tc_CTkinhphihoatdong" && s_Tenform!="tc_CTkinhphiduan" && s_Tenform!="tc_mKPI"&& s_Tenform!="tc_mKPI_longan" && s_Tenform!="TamungKP_KhoBac"&&s_Tenform!="TamungKP_KhoBac_TM")
				{
					dtDmNhomMuc=a.get_DMNhomMuc().Tables[0];
					listNhomMuc.TextMember="nhom";
					listNhomMuc.DisplayMember="tennhom";
					listNhomMuc.ValueMember="tennhom";
				}
				else
				{
					dtDmNhomMuc=a.get_DMMuc().Tables[0];
					listNhomMuc.TextMember="mtm";
					listNhomMuc.DisplayMember="ttk";
					listNhomMuc.ValueMember="ttk";

                    if(s_Tenform=="tc_CTkinhphihoatdong")
					//HOAT DONG
					dtDmHoatdong=a.get_DMHoatdong("tc_CTkinhphihoatdong").Tables[0];
					if(s_Tenform=="tc_CTkinhphiduan")
					dtDmHoatdong=a.get_DMHoatdong("tc_CTkinhphiduan").Tables[0];
				}	
				//list nhommuc
				listNhomMuc.DataSource=dtDmNhomMuc;

				//listbox HOAT DONG				
				listhoatdong.TextMember="ma";
				listhoatdong.DisplayMember="ten";
				listhoatdong.ValueMember="ten";
				listhoatdong.DataSource=dtDmHoatdong;
			}
			catch {}
		}


		/// <summary>
		/// load data LISTBOX NGUON
		/// </summary>		
		private void f_LoadNguon(System.Data.DataTable dtm)
		{	listNguon.TextMember="mang";
			listNguon.DisplayMember="ten";
			listNguon.ValueMember="ten";
			listNguon.DataSource=dtm;
		}


		private void Filter_List(string s_Dkloc,int i_Loai)
		{
			try
			{
				switch (i_Loai)
				{
						//load TAI KHOAN
					case 1:
					{
						CurrencyManager cm= (CurrencyManager)BindingContext[listTaikhoan.DataSource];
						System.Data.DataView dv=(System.Data.DataView)cm.List;
						dv.RowFilter="stk like '%"+s_Dkloc.Trim()+"%'";
						break;
					}						
						// load NHOM BAO CAO
					case 2:
					{
						CurrencyManager cm= (CurrencyManager)BindingContext[listnhombc.DataSource];
						System.Data.DataView dv=(System.Data.DataView)cm.List;
						dv.RowFilter="ma like '%"+s_Dkloc.Trim()+"%'";
						break;
					}
						//load CHUONG
					case 3:
					{
						CurrencyManager cm= (CurrencyManager)BindingContext[listchuong.DataSource];
						System.Data.DataView dv=(System.Data.DataView)cm.List;
						dv.RowFilter="ma like '%"+s_Dkloc.Trim()+"%'";
						break;
					}
						//load HOAT DONG
					case 4:
					{
						CurrencyManager cm= (CurrencyManager)BindingContext[listhoatdong.DataSource];
						System.Data.DataView dv=(System.Data.DataView)cm.List;
						dv.RowFilter="ma like '%"+s_Dkloc.Trim()+"%'";
						break;
					}
						//load LOAI TAI KHOAN
					case 5:
					{
						CurrencyManager cm= (CurrencyManager)BindingContext[listLoaikhoan.DataSource];
						System.Data.DataView dv=(System.Data.DataView)cm.List;
						dv.RowFilter="lk like '%"+s_Dkloc.Trim()+"%'";
						break;
					}
						//load NGUON KINH PHI
					case 6:
					{
						CurrencyManager cm= (CurrencyManager)BindingContext[listNguon.DataSource];
						System.Data.DataView dv=(System.Data.DataView)cm.List;
						dv.RowFilter="mang like '%"+s_Dkloc.Trim()+"%'";
						break;
					}
						// load NHOM MUC
					case 7:
					{
						CurrencyManager cm= (CurrencyManager)BindingContext[listNhomMuc.DataSource];
						System.Data.DataView dv=(System.Data.DataView)cm.List;
						dv.RowFilter="nhom like '%"+s_Dkloc.Trim()+"%'";
						break;
					}			
					default:
						break;
				}

			}
			catch{}
		}
		

		private bool Kiemtra()
		{
			if (txtSotaikhoan.Text==""&&kt_chon_kp==false&&b_form==false)
			{
				MessageBox.Show("Vui lòng nhập số tài khoản!","Chú ý!");
				txtSotaikhoan.Focus();
				return false;
			}		
			if(s_Tenform=="tc_CTkinhphihoatdong" || s_Tenform=="tc_CTkinhphiduan")
			{
				if(txthoatdong.Text=="")
				{
					MessageBox.Show("Vui lòng nhập hoạt động!","Thông báo!");
					txthoatdong.Focus();
					return false;
				}
				
				else
					if(txtNguonGoc.Text=="")
				{
					MessageBox.Show("Vui lòng nhập nguồn kinh phí!","Thông báo!");
					txtNguonGoc.Focus();
					return false;
				}
			}
			return true;
		}


		private void hide_List()
		{
			if(!listTaikhoan.Focused) listTaikhoan.Hide();
			if(!listnhombc.Focused) listnhombc.Hide();
			if(!listchuong.Focused) listchuong.Hide();
			if(!listhoatdong.Focused) listhoatdong.Hide();
			if(!listNguon.Focused) listNguon.Hide();
			if(!listNhomMuc.Focused) listNhomMuc.Hide();
			if(!listLoaikhoan.Focused) listLoaikhoan.Hide();
		}
		

		/// <summary>
		/// Loai display (form giao du toan) - giao du toan: 1 - xuat ra man hinh; 2 - xuat ra may in; 3 - xuat ra excel.
		/// </summary>		
		private void Display(int loai)			
		{
			string s_yyyy=numNam.Value.ToString();
			string s_yy=s_yyyy.Substring(2,2);			
			int mm1=int.Parse(numTuthang.Value.ToString());
			int mm2=int.Parse(numDenthang.Value.ToString());
			//Tinh lai cac gia tri thang theo dieu kien chon ngay thang.
			switch (cboChonthang.SelectedIndex)
			{
				case 1:
					mm1=(mm2*3)-2;
					mm2=mm2*3;
					break;
				case 2:
					mm1=1;
					mm2=12;
					break;
			}

			string s_mm1=mm1.ToString().PadLeft(2,'0');
			string s_mm2=mm2.ToString().PadLeft(2,'0');			
			if (s_mm1==s_mm2)
			{
				ngaythangnam="Tháng " + s_mm1 + " Năm " + s_yyyy; 
			}
			else
			{
				ngaythangnam="Từ Tháng " + s_mm1 + " Đến Tháng " + s_mm2 + " Năm " + s_yyyy; 
			}				
			if (Kiemtra()) //Kiem tra dieu kien nhap vao.
			{
				frmReportNguon_class accMyform=new frmReportNguon_class();
				ds_Data=new DataSet();
				string s_IDtk="",s_IDnhombc="",s_IDlk="",idChuong="",idHoatdong="",s_IDNhomMuc="",idNguon="";
				if (txtSotaikhoan.Text!="") s_IDtk=a.get_ID_Stk(txtSotaikhoan.Text.Trim());
				if(txtnhombc.Text!="")s_IDnhombc=a.getrowbyid(dtDmnhombc,"ma='"+txtnhombc.Text.Trim()+"'")["id"].ToString();
				if (txtLoaikhoan.Text!="") s_IDlk=a.getrowbyid(dtDmlk,"lk='"+txtLoaikhoan.Text.Trim()+"'")["id"].ToString().Trim();
				if (txtchuong.Text!="") idChuong=a.getrowbyid(dtDmChuong,"ma='"+txtchuong.Text.Trim()+"'")["id"].ToString().Trim();
				if (txthoatdong.Text!="") idHoatdong=a.getrowbyid(dtDmHoatdong,"ma='"+txthoatdong.Text.Trim()+"'")["id"].ToString().Trim();
				if (txtNhomMuc.Text!="") s_IDNhomMuc=a.getrowbyid(dtDmNhomMuc,"nhom='"+txtNhomMuc.Text.Trim()+"'")["id"].ToString().Trim();
				if (txtNguonGoc.Text!="") idNguon=a.getrowbyid(dtDmNguon,"mang='"+txtNguonGoc.Text.Trim()+"'")["id"].ToString().Trim();
				switch(s_Tenform)
				{
					case "GiaoDuToan":
						ds_Data=accMyform.SoTheoDoiGiaoDuToan(a,s_IDtk,s_IDlk,idChuong,idHoatdong,idNguon,s_IDNhomMuc,s_yy);
						accMyform.Dispose();
						break;
					case "dutoan_nskhobac":
						ds_Data=accMyform.dutoan_nskhobac(a,s_IDlk,s_IDtk,s_mm1,s_mm2,s_yy,s_yyyy,idChuong,idHoatdong,s_IDNhomMuc,idNguon,s_IDnhombc);
						accMyform.Dispose();
						break;
				}
				try
				{
					if (ds_Data==null) MessageBox.Show("Không có số liệu !","Thông báo !");
					else
					{	
						switch(loai)
						{
							case 1:
								if (txtTentaikhoan.Text!="")
									s_loaidutoan=txtTentaikhoan.Text;								
								if (txtLoaikhoan.Text!="")
								{
									s_loai = txtLoaikhoan.Text.Trim().Split('-')[0].ToString();
									s_khoan= txtLoaikhoan.Text.Trim().Split('-')[1].ToString();
								}
								if (txtNhomMuc.Text!="") 
									s_nhommuc = txtNhomMuc.Text + "-" + txtTenNhomMuc.Text;
//							
									frmReport f=new frmReport(a,ds_Data,s_Report.ToString(),s_loaidutoan,s_loai,s_khoan,s_nhommuc,ngayin,ngaythangnam,text);
									f.ShowDialog();	
									break;								
								
							case 2:
								string s_ExcelError=exportExcel.expExcel(a,ds_Data,"",ngaythangnam,"","","","","","","","","","","",s_Report.ToString());
								if (s_ExcelError!="")
									MessageBox.Show(s_ExcelError,"Thông báo!");
								break;
							case 3:
								string s_InError=Print.Printer(a,ds_Data,"",ngaythangnam,"","","","","","","","","","","",s_Report.ToString(),s_Pagesize,i_Kieuin,i_Banin); //Kieu - ngang hoac doc ; Copy - so ban in.
								if (s_InError=="")
									MessageBox.Show("Đã in xong báo cáo","Thông báo!");
								else MessageBox.Show(s_InError,"Lỗi in báo cáo!");
								break;
							default:	
								frmReport fdd=new frmReport(a,ds_Data,s_Report.ToString(),s_loaidutoan,s_loai,s_khoan,s_nhommuc,ngayin,ngaythangnam,text);
								fdd.ShowDialog();	
								break;
						}						
					}
				}
				catch (Exception Ex)
				{
					MessageBox.Show("Error : " + Ex ,"Thông báo !");
				}
			}
		}
		
		
		/// <summary>
		/// Loai display (form nhan du toan) - nhan du toan: 1 - xuat ra man hinh; 2 - xuat ra may in; 3 - xuat ra excel.
		/// </summary>		 
		private void Display_(int loai)
		{
			if (Kiemtra())
			{	int yy=int.Parse(numNam.Value.ToString());
				int mm1=int.Parse(numTuthang.Value.ToString());
				int mm2=int.Parse(numDenthang.Value.ToString());
				//Tinh lai cac gia tri thang theo dieu kien chon ngay thang.
				switch (cboChonthang.SelectedIndex)
				{
					case 1:
						mm1=(mm2*3)-2;
						mm2=mm2*3;
						break;
					case 2:
						mm1=1;
						mm2=12;
						break;
				}

				string s_mm1=mm1.ToString().PadLeft(2,'0');
				string s_mm2=mm2.ToString().PadLeft(2,'0');
				string s_yyyy=yy.ToString().Trim();
				string s_yy=s_yyyy.Substring(2,2);
				if (s_mm1==s_mm2)
				{
					ngaythangnam="Tháng " + s_mm1 + " Năm " + s_yyyy; 
				}
				else
				{
					ngaythangnam="Từ Tháng " + s_mm1 + " Đến Tháng " + s_mm2 + " Năm " + s_yyyy; 
				}	
				//Kiem tra va canh bao cac thang chua tinh so du.
				string s_Thangnam=a.kt_Tinhsodu((mm2).ToString(),s_yy);
				if (s_Thangnam!="")
				{
					MessageBox.Show("Các tháng "+s_Thangnam.Substring(0,s_Thangnam.Length-1)+" chưa tính số dư!","Chú ý!");
					//xac minh co tinh so du
					if (MessageBox.Show ("Bạn có muốn kiểm tra số dư không ?",this.Text,MessageBoxButtons.YesNo, MessageBoxIcon.Question)== DialogResult.Yes)
					{
						//tinh so du
						string sql="",_tu="",_den="";
						_den=s_mm2+s_yyyy.Substring(2,2);			
						//lay thang tu						
						sql="select mmyy from (select *  from a_dtsd where substr(trim(mmyy),3,4)='"+s_yy+"' order by mmyy asc) where rownum=1";
						DataSet ds=new DataSet();
						ds=a.get_data(sql);
						if(ds!=null && ds.Tables[0].Rows.Count>0)
							_tu=ds.Tables[0].Rows[0]["mmyy"].ToString();
						else _tu=s_mm1+s_yyyy.Substring(2,2);			
						if (!a.bYyyy(s_yyyy))
						{
							MessageBox.Show("Số liệu năm "+s_yyyy+" chưa tạo !",a.Msg);
							return;
						}
						string s=a.KiemtraFb(_tu,_den);
						if (s!="")
						{
							MessageBox.Show("Số liệu tháng :"+s.Substring(0,s.Length-1)+" Năm "+s_yyyy+" bị khóa !");    		
							return;
						}
						else 
						{
							Cursor=Cursors.WaitCursor;
							a.KiemtraFb(_tu,_den,i_Iduser);
							Cursor=Cursors.Default;
						}
						//a.updSodu(_tu,a.Mmyy_sau(_den),i_Iduser,false);
						MessageBox.Show("Đã kiểm tra số dư cuối tháng "+_tu.Substring(0,2)+" đến tháng "+_den.Substring(0,2)+" năm 20"+s_yy+" !",a.Msg);					
						//
					}
				}
				frmReportNguon_class accMyform=new frmReportNguon_class();
				ds_Data=new DataSet();
				string s_IDtk="",s_IDnhombc="",s_IDlk="",idChuong="",idHoatdong="",s_IDNhomMuc="",idNguon="";				
				if(s_Tenform=="TamungKP_KhoBac"||s_Tenform=="TamungKP_KhoBac_TM")
					if (txtSotaikhoan.Text!="") s_IDtk=a.get_ID_Stk(txtSotaikhoan.Text.Trim(),"TamungKP_KhoBac");	
				else if(s_Tenform!="TamungKP_KhoBac"||s_Tenform!="TamungKP_KhoBac_TM")
						if (txtSotaikhoan.Text!="") s_IDtk=a.get_ID_Stk(txtSotaikhoan.Text.Trim());	
				if(txtnhombc.Text!="")s_IDnhombc=a.getrowbyid(dtDmnhombc,"ma='"+txtnhombc.Text.Trim()+"'")["id"].ToString();										  
				if (txtLoaikhoan.Text!="") s_IDlk=a.getrowbyid(dtDmlk,"lk='"+txtLoaikhoan.Text.Trim()+"'")["id"].ToString().Trim();
				if (txtchuong.Text!="") idChuong=a.getrowbyid(dtDmChuong,"ma='"+txtchuong.Text.Trim()+"'")["id"].ToString().Trim();
				if (txthoatdong.Text!="") idHoatdong=a.getrowbyid(dtDmHoatdong,"ma='"+txthoatdong.Text.Trim()+"'")["id"].ToString().Trim();
				if(s_Tenform!="tc_CTkinhphihoatdong" && s_Tenform!="tc_CTkinhphiduan" && s_Tenform!="tc_mKPI" && s_Tenform!="TamungKP_KhoBac"&&s_Tenform!="TamungKP_KhoBac_TM")
					if (txtNhomMuc.Text!="") s_IDNhomMuc=a.getrowbyid(dtDmNhomMuc,"nhom='"+txtNhomMuc.Text.Trim()+"'")["id"].ToString().Trim();				
				if(s_Tenform=="tc_CTkinhphihoatdong" || s_Tenform=="tc_CTkinhphiduan" || s_Tenform=="tc_mKPI" || s_Tenform=="TamungKP_KhoBac"||s_Tenform=="TamungKP_KhoBac_TM")
					if (txtNhomMuc.Text!="") s_IDNhomMuc=txtNhomMuc.Text;
				if (txtNguonGoc.Text!="") idNguon=a.getrowbyid(dtDmNguon,"mang='"+txtNguonGoc.Text.Trim()+"'")["id"].ToString().Trim();
				if(s_Tenform=="NhanDuToan")
				{
					ds_Data=accMyform.SoTheoDoiNhanDuToan(a,s_IDtk,s_IDlk,idChuong,idHoatdong,idNguon,s_IDNhomMuc,s_mm1,s_mm2,s_yy);
					accMyform.Dispose();
				}
				else
					if(s_Tenform=="tc_CTkinhphihoatdong")
				{				
					ds_Data=accMyform.tc_ctkinhphihoatdong(a,s_IDlk,s_mm1,s_mm2,s_yy,s_yyyy,idChuong,idHoatdong,s_IDNhomMuc,s_IDnhombc,idNguon);
					accMyform.Dispose();
				}
				else
					if(s_Tenform=="tc_CTkinhphiduan")
				{
					ds_Data=accMyform.tc_ctkinhphiduan(a,s_IDlk,s_mm1,s_mm2,s_yy,s_yyyy,idChuong,idHoatdong,s_IDNhomMuc,s_IDnhombc,idNguon);
					accMyform.Dispose();
				}
				else 
					if(s_Tenform=="tc_mKPI_longan")
				{		
					ds_Data=accMyform._trangfsmKPI_la(a,s_IDlk,s_mm1,s_mm2,s_yy,s_yyyy,idChuong,idHoatdong,s_IDNhomMuc,s_IDnhombc,idNguon);
					
				}
					
					if(s_Tenform=="tc_mKPI")
						{							
							ds_Data=accMyform.ds_tc_fsmKPI(a,s_IDlk,s_mm1,s_mm2,s_yy,s_yyyy,idChuong,idHoatdong,s_IDNhomMuc,s_IDnhombc,idNguon);
							accMyform.Dispose();
						}
				else 
					if(s_Tenform=="TamungKP_KhoBac"||s_Tenform=="TamungKP_KhoBac_TM")
				{
					ds_Data=accMyform.TamungKP_KhoBac(a,s_IDlk,s_IDtk,s_mm1,s_mm2,s_yy,s_yyyy,idChuong,idHoatdong,s_IDNhomMuc,idNguon,s_IDnhombc);
					accMyform.Dispose();
				}
				try
				{
					if (ds_Data==null) MessageBox.Show("Không có số liệu !","Thông báo !");
					else
					{
						switch(loai)
						{
							case 1:
								if (txtTentaikhoan.Text!="")
									s_loaidutoan=txtTentaikhoan.Text;								
								if (txtLoaikhoan.Text!="")
								{
									s_loai = txtLoaikhoan.Text.Trim().Split('-')[0].ToString();
									s_khoan= txtLoaikhoan.Text.Trim().Split('-')[1].ToString();
								}
								if (txtNhomMuc.Text!="") 
									s_nhommuc = txtNhomMuc.Text + "-" + txtTenNhomMuc.Text;									
								if(s_Tenform=="tc_CTkinhphihoatdong")
								{
									string s_nguon="";
									if(txtTenNguonGoc.Text!="")
										s_nguon="NGUỒN KINH PHÍ: "+txtTenNguonGoc.Text;
									//ds_Data.WriteXml("..\\xml\\KT_tc_CTkinhphihoatdong.xml",XmlWriteMode.WriteSchema);
									frmReport f= new frmReport(a,ds_Data,ngaythangnam,s_nguon,chuky1,s_Report);
									
									f.ShowDialog();
								}	
								else
									if(s_Tenform=="tc_CTkinhphiduan")
								{
									string s_tenda="",s_maso="",s_thuocCT="",s_khoidau="",s_ketthuc="",s_cqth="";
									Decimal d_tongso=0;
									//string s_loai="",s_khoan="";
									if(txtLoaikhoan.Text!="")
									{
										s_loai=txtLoaikhoan.Text.Trim().Split('-')[0].ToString();
										s_khoan=txtLoaikhoan.Text.Trim().Split('-')[1].ToString();
									}
									if(txtNguonGoc.Text!="")
									{
										//lay thong tin tu bang a_dmng
										string sql="";
										sql="select * from "+a.user+".a_dmng where loaikp=0 and mang="+txtNguonGoc.Text;
										DataSet ds=new DataSet();
										ds=a.get_data(sql);
										if(ds!=null && ds.Tables[0].Rows.Count>0)
										{
											s_tenda=ds.Tables[0].Rows[0]["ten"].ToString();
											s_maso=ds.Tables[0].Rows[0]["mada"].ToString();
											s_thuocCT=ds.Tables[0].Rows[0]["thuocct"].ToString();
											s_khoidau=ds.Tables[0].Rows[0]["ngaybd"].ToString();
											s_ketthuc=ds.Tables[0].Rows[0]["ngaykt"].ToString();
											s_cqth=ds.Tables[0].Rows[0]["coquanth"].ToString();
											d_tongso=Convert.ToDecimal(ds.Tables[0].Rows[0]["tongkpdd"].ToString());											
										}
									}
									frmReport f;
									if(rdb2h.Checked)
										f = new frmReport(a,ds_Data,ngaythangnam,"","","","","","KT_ChiTietKinhPhiDuAn1.rpt",s_yyyy,s_tenda,s_thuocCT,s_maso,s_khoidau,s_ketthuc,s_loai,s_khoan,"",s_cqth,d_tongso);
									else
										f = new frmReport(a,ds_Data,ngaythangnam,"","","","","","KT_ChiTietKinhPhiDuAn12.rpt",s_yyyy,s_tenda,s_thuocCT,s_maso,s_khoidau,s_ketthuc,s_loai,s_khoan,"",s_cqth,d_tongso);													
									f.ShowDialog();									
								}		
								else if(s_Tenform=="tc_mKPI")
								{
									frmReport f = new frmReport(a,ds_Data,ngaythangnam,"","","KT_TongHopTinhHinhKP_QuyetToanKP1.rpt");
									f.ShowDialog();									
								}
								else if(s_Tenform=="tc_mKPI_longan")
								{
									frmReport f;									
									f = new frmReport(a,ds_Data,ngaythangnam,"","","KT_rTongHopTinhHinhKP_QuyetToanKP1_la.rpt");
									f.ShowDialog();
									frmReport f1; 
									f1= new  frmReport(a,ds_Data,ngaythangnam,"","","KT_rTongHopTinhHinhKP_QuyetToanKPII_la.rpt");
									f1.ShowDialog();
								}
								else if(s_Tenform=="TamungKP_KhoBac"||s_Tenform=="TamungKP_KhoBac_TM")
								{
									string loaitu="",nguonkp="";
									if(txtSotaikhoan.Text!="")
									{
										nguonkp=txtTentaikhoan.Text;
										if(txtSotaikhoan.Text.Trim().Substring(0,3)=="336")
											loaitu="Đã giao dự toán";
										else
											loaitu="Chưa giao dự toán";										
									}
									frmReport f;
									if(s_Tenform=="TamungKP_KhoBac")
										f = new frmReport(a,ds_Data,ngaythangnam,loaitu,nguonkp,"KT_Sotheodoi_tukpkb.rpt");
									else
										f = new frmReport(a,ds_Data,ngaythangnam,loaitu,nguonkp,"KT_DCTamungThanhToanKPNS_KhoBac.rpt");
									f.ShowDialog();
								}								
								else 
								{
									frmReport f=new frmReport(a,ds_Data,s_Report.ToString(),s_loaidutoan,s_loai,s_khoan,s_nhommuc,ngayin,ngaythangnam,text);
									f.ShowDialog();	
								}
								break;
							case 2:
								string s_ExcelError=exportExcel.expExcel(a,ds_Data,"",ngaythangnam,"","","","","","","","","","","",s_Report.ToString());
								if (s_ExcelError!="")
									MessageBox.Show(s_ExcelError,"Thông báo!");
								break;
							case 3:
								string s_InError=Print.Printer(a,ds_Data,"",ngaythangnam,"","","","","","","","","","","",s_Report.ToString(),s_Pagesize,i_Kieuin,i_Banin); //Kieu - ngang hoac doc ; Copy - so ban in.
								if (s_InError=="")
									MessageBox.Show("Đã in xong báo cáo","Thông báo!");
								else MessageBox.Show(s_InError,"Lỗi in báo cáo!");
								break;							
						}
					}
						
				}
				catch (Exception Ex)
				{
					MessageBox.Show("Error : " + Ex ,"Thông báo !");
				}
			}
		}
	
		#endregion	

	}
}
